function [ max_point, segment_point ] = segmentation( delta_acc )

max_threshold = 0.08;
intval_3 = 3;
intval_5 = 5;
intval_10 = 10;
intval_15 = 15;
intval_20 = 20;
len = length(delta_acc);
max_count = 1;
max_intval = 30;
left_max_time = -30;

for i = 2 : len - 1
    if (delta_acc(i) > max_threshold) && (delta_acc(i) > delta_acc(i - 1)) && (delta_acc(i) > delta_acc(i + 1))
        if (i - intval_20 >= 1) && (i + intval_20 <= len)
            if (delta_acc(i) > delta_acc(i - intval_3)) && (delta_acc(i) > delta_acc(i + intval_3))
                if (delta_acc(i) > delta_acc(i - intval_5)) && (delta_acc(i) > delta_acc(i + intval_5))
                    if (delta_acc(i) > delta_acc(i - intval_10)) && (delta_acc(i) > delta_acc(i + intval_10))
                        if (delta_acc(i) > delta_acc(i - intval_15)) && (delta_acc(i) > delta_acc(i + intval_15))
                            if (delta_acc(i) > delta_acc(i - intval_20)) && (delta_acc(i) > delta_acc(i + intval_20))
                                % judge the interval between two neighbor max point
                                if (i - left_max_time) > max_intval
                                    max_point(max_count) = i;
                                    max_count = max_count + 1;
                                else
                                    if delta_acc(i) > delta_acc(max_point(max_count - 1))
                                        max_point(max_count - 1) = i;
                                    end
                                end
                                left_max_time = i;
                            end
                        end
                    end
                end
            end
        end
    end
end


min_threshold = 0.025;
segment_point_count = 1;
min_val = Inf;
for i = 1 : max_point(1)
    k = max_point(1) - i + 1;
    if delta_acc(k) < min_threshold
        segment_point(segment_point_count) = k;
        break;
    end
    
    if delta_acc(k) < min_val
        min_val = delta_acc(k);
        segment_point(segment_point_count) = k;
    end
end
segment_point_count = segment_point_count + 1;


if length(max_point) > 1
    for i = 1 : length(max_point) - 1
        min_val = Inf;
        for j = max_point(i) : max_point(i + 1)
            if delta_acc(j) < min_val
                min_val = delta_acc(j);
                segment_point(segment_point_count) = j;
            end
        end
        segment_point_count = segment_point_count + 1;
    end
end


min_val = Inf;
for i = max_point(length(max_point)) : len
    if delta_acc(i) < min_threshold
        segment_point(segment_point_count) = i;
        break;
    end
    
    if delta_acc(i) < min_val
        min_val = delta_acc(i);
        segment_point(segment_point_count) = i;
    end
end

end